<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">


<p:dialog id="dialogCadastro" modal="true" width="50%" position="top"
	appendTo="@(body)" resizable="true" draggable="true" closable="false"
	widgetVar="dialogCadastroCondicao"
	header="Cadastro de Condição de Pagamento">
	<p:ajax event="close" listener="#{condicaoPagamentoMB.close}"
		update="frmDialogCondicao" />
	<h:form id="frmDialogCondicao">

		<h:panelGrid columns="2">

			<p:outputLabel value="Codigo:"></p:outputLabel>
			<p:inputText
				value="#{condicaoPagamentoMB.condicaoPagamentoSelecionada.codigo}"
				disabled="true"></p:inputText>

			<p:outputLabel value="Descrição:" for="descricao"></p:outputLabel>
			<p:inputText id="descricao"
				value="#{condicaoPagamentoMB.condicaoPagamentoSelecionada.descricao}"
				size="60" disabled="#{condicaoPagamentoMB.consultando}"
				required="true" requiredMessage="Descrição é obrigatória!"
				maxlength="80"></p:inputText>

		</h:panelGrid>
		<h:panelGrid>

			<h:panelGroup id="incdia">
				<h:panelGrid columns="3"
					rendered="#{not condicaoPagamentoMB.consultando}">
					<p:outputLabel value="Dia:"></p:outputLabel>
					<p:selectOneMenu value="#{condicaoPagamentoMB.dia}" size="5">
					<f:selectItem itemLabel="" itemValue="#{null}"></f:selectItem>
						<f:selectItems value="#{condicaoPagamentoMB.listaInteiro}"
							var="num" itemLabel="#{num}" itemValue="#{num}"></f:selectItems>
					</p:selectOneMenu>
					<p:commandButton id="btnAdd" value="Incluir"
						icon="ui-icon-circle-plus" ajax="true"
						actionListener="#{condicaoPagamentoMB.addDia}" update="tabeladia">
					</p:commandButton>

				</h:panelGrid>
			</h:panelGroup>

			<h:panelGroup id="outpaneltbdia">
				<p:dataTable id="tabeladia" var="itemvenc"
					value="#{condicaoPagamentoMB.condicaoPagamentoSelecionada.dias}"
					paginatorPosition="bottom" paginator="true" rows="3"
					emptyMessage="Não há registros"
					paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					currentPageReportTemplate="(Página: {currentPage}/{totalPages})">
					<f:facet name="header">Dias</f:facet>
					<p:column headerText="Dia">
						<p:outputLabel value="#{itemvenc}"></p:outputLabel>
					</p:column>
					<p:column headerText="Ação" style="text-align:center"
						rendered="#{not condicaoPagamentoMB.consultando}">
						<p:commandLink update=":frmDialogCondicao:tabeladia">
							<p:graphicImage value="/imagens/x.png" height="14"></p:graphicImage>
							<p:collector unique="true"
								removeFrom="#{condicaoPagamentoMB.condicaoPagamentoSelecionada.dias}"
								value="#{itemvenc}"></p:collector>
						</p:commandLink>
					</p:column>

				</p:dataTable>
			</h:panelGroup>
		</h:panelGrid>

		<h:panelGrid columns="2" style="border:0px">
			<p:commandButton value="Confirma"
				actionListener="#{condicaoPagamentoMB.salvar}"
				rendered="#{not condicaoPagamentoMB.consultando}"
				update=":frmTab:tabela,:mensagem"
				oncomplete="validaDialog(args,'dialogCadastroCondicao','frmDialogCondicao:dialogCadastro')" />


			<p:commandButton value="Cancela"
				onclick="dialogCadastroCondicao.hide()" immediate="true" />

		</h:panelGrid>

	</h:form>
</p:dialog>

</html>